import { Channels } from '/imports/models/Channels';

Template.exploreChannelContent.onCreated(function() {
  this.autorun(() => {
    this.infiniteScroll({
      query: {
        text: Router.current().params.query.channel
      },
      publication: 'Explore.Channels.ByText',
      countPublication: 'Explore.Channels.ByText.Counts',
      perPage: 20
    });
  });
});

Template.exploreChannelContent.helpers({
  results: function() {
    return Channels.find({}, { 
      limit: Template.instance().getLimit(),
      sort: { createdAt: -1 } 
    });
  },
  loading: function() {
    return !Template.instance().resultSub.ready();
  }
});